<?php

namespace app\hospital\model;
use think\facade\Db;
use think\facade\Request;
use think\Model;
class doctoruser extends Model
{
    function search()
    {
        $key=Request::param('key');
        //  $data=Bookinfo::where("bookname","like","%".$key."%")->paginate(['list_rows'=>4,'query'=>Request::param()]);

        $data=doctoruser::withSearch(['id','name','role'],[
            'id'=>$key,
            'name'=>$key,
            'role'=>$key
        ])->paginate(['list_rows'=>3,'query'=>Request::param()]);
//        dump(Db::getlastsql());
        // halt($data->toArray());
        return $data;
    }

    function searchnameAttr($q,$v){
        //  halt($q,$v,$d);
        $q->whereor('name','like','%'.$v.'%');

    }
    function searchidAttr($q,$v){
        $q->whereor('id','like','%'.$v.'%');
    }
    function searchroleAttr($q,$v){
        $q->whereor('role','like','%'.$v.'%');
    }
}